package com.rongke.web;

import com.rongke.commons.JsonResp;
import com.rongke.mapper.SideEffectMapper;
import com.rongke.model.SideEffect;
import com.rongke.service.SideEffectService;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigInteger;
import java.util.List;

/**
 * @SideEffectController
 * @副作用Controller
 * @version : Ver 1.0
 */
@RestController
@RequestMapping(value="/api/sideEffect")
@Transactional
public class SideEffectController {
    private Logger log = Logger.getLogger(this.getClass());
    @Autowired
    private SideEffectService sideEffectService;

    /**
     * @添加副作用
     * @param sideEffect
     * @return 返回值JsonResp
     */
    @RequestMapping(value="/add", method = RequestMethod.POST)
    public JsonResp addSideEffect(@RequestBody SideEffect sideEffect){
        log.debug("添加副作用");
        sideEffectService.insert(sideEffect);
        return JsonResp.ok(sideEffect);
    }

    /**
     * @修改副作用
     * @param sideEffect
     * @return 返回值JsonResp
     */
    @RequestMapping(value="/update", method = RequestMethod.POST)
    public JsonResp updateSideEffect(@RequestBody SideEffect sideEffect){
        log.debug("修改副作用");
        sideEffectService.updateById(sideEffect);
        return JsonResp.ok(sideEffect);
    }
    /**
     * @根据id查找副作用
     * @param id
     * @return 返回值JsonResp
     */
    @RequestMapping(value="/selectOne", method = RequestMethod.GET)
    public JsonResp selectSideEffect(Long id){
        log.debug("查找副作用");
        SideEffect sideEffect = sideEffectService.selectById(id);
        return JsonResp.ok(sideEffect);
    }


}
